package org.paul.agoto.manager;

import org.paul.agoto.bean.LoginBean;
import org.paul.agoto.ui.helper.Constants;
import org.paul.library.base.BaseBean;
import org.paul.library.manager.ThreadManager;

import java.util.Map;

import static org.paul.agoto.BuildConfig.API_HOST;
import static org.paul.agoto.BuildConfig.API_LV;
import static org.paul.agoto.helper.StringHelper.format;

public class ApiManager {

    private final String TAG = getClass().getSimpleName();

    private static class Holder {
        private static final ApiManager instance = new ApiManager();
    }

    private ApiManager() {
    }

    public static ApiManager getInstance() {
        return Holder.instance;
    }

    public <T extends BaseBean> void login(Map<String, Object> params, ThreadManager.HandleRet<LoginBean> handleRet) {
        ThreadManager.getInstance().submitPost(format(API_HOST + Constants.LOGIN_API, API_LV), params, LoginBean.class,
                handleRet);
    }

}
